package com.learn.project2.controller.wx.search;



import com.learn.project2.model.vo.wx.search.SearchIndexVO2;
import com.learn.project2.service.wx.search.SearchService2;
import com.learn.project2.utils.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;


/**
 * @description: 微信小程序 /wx/search的控制方法
 * @author 曹源
 * @date  2022/1/10 15:10
 * @version 1.0
 */
@RestController
@RequestMapping("wx/search")
public class SearchController2 {

    @Autowired
    SearchService2 searchService2;

    Result result;

    /**
     * @description: 微信小程序 /wx/search/index的控制方法
     * @param:
     * @return:
     * @author 曹源
     * @date: 2022-01-10 15:18
     */
    @RequestMapping("index")
    public Result index() {
        SearchIndexVO2 searchIndexVO = searchService2.selectIndex();
        return result.ok(searchIndexVO);
    }
   /**
    * @description: 微信小程序 /wx/search/helper的控制方法
    * @param:
    * @return:
    * @author 曹源
    * @date: 2022-01-10 16:49
    */
    @RequestMapping("helper")
    public Result helper(String keyword) {
        ArrayList<String> data= searchService2.searchHelper(keyword);
        return result.ok(data);
    }
    /** 
     * @description: 微信小程序 /wx/search/clearhistory的控制方法 
     * @param:  
     * @return:  
     * @author 曹源
     * @date: 2022-01-10 17:17 
     */ 
    @PostMapping ("clearhistory")
    public Result All() {
        searchService2.deletehistory();
        return result.ok();
    }



}
